Conversation
elhb
force-pushed
the
PNA-3532
branch
3 times, most recently
from
September 24, 2026 11:32
71a7191 to
3a3b424
Compare
Keep mean difference on the original matrix, like PixelatorR RunDAA. Co-authored-by: Cursor <cursoragent@cursor.com>
elhb
added this pull request to stack #473
September 25, 2026 11:44
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes
differential_abundancevalid on signed CLR.differenceis stillmean(target) - mean(reference)on the originalmatrix, matching PixelatorR
RunDAA(fc.name = "difference"). Wilcoxonruns on a test-only copy where each marker is shifted so its minimum is 0.
That shift is the same for every cell, so ranks (and thus p-values) match a
Wilcoxon on the original CLR. Scanpy still computes log-fold changes
internally, which break on negatives; we do not use those values.
Based on
PNA-3531.Fixes: PNA-3532
Type of change
How Has This Been Tested?
test_differential_abundance_returns_expected_columnstest_differential_abundance_layer_from_obsmtest_differential_abundance_group_vars_splits_rowstest_differential_abundance_invalid_reference_raisestest_differential_abundance_signed_clr_keeps_original_difference_signTiny "Offline" R vs Python sanity check
Frozen 5-cell PNA PBMC
.pxl, 20 copies per cell with lognormal count noise, 50 treated vs 50 control (stratified by source cell). Planted count fold-changes, then pixelator CLR. Same CLR matrix in Pythondifferential_abundanceand pixelatorRRunDAA(Bonferroni).Wilcoxon p-values are not bit-identical (scanpy vs Seurat). Effect size is the same mean difference on the original CLR.
PR checklist:
pyproject.tomland cited it properlyNote
Medium Risk
Changes the Wilcoxon input path for signed CLR abundance matrices in a core analysis helper, though rank-preserving shifts and added tests reduce regression risk.
Overview
differential_abundancenow supports signed CLR (matrices with negative values) without changing how effect sizes are reported.When negatives are present, Wilcoxon runs on a test-only copy: each marker is shifted by its negative minimum so values are non-negative, using the same offset for every cell so ranks (and p-values) stay equivalent to Wilcoxon on the original CLR.
difference,pct_1, andpct_2are still computed on the original matrix, matching pixelatorRRunDAAmean-difference behavior. The previous warning plus log2 warning suppression is replaced by an info log and a dedicated_shift_markers_to_nonnegativehelper; CHANGELOG documents the behavior change.Tests now assert the input matrix is untouched,
differencematches the planted group means, and p-values are finite on signed CLR.Reviewed by Cursor Bugbot for commit ba89e99. Bugbot is set up for automated code reviews on this repo. Configure here.